#region CVS Log
/*
 * Version:
 *   $Id: ID3Genre.cs,v 1.2 2004/11/10 06:51:55 cwoodbury Exp $
 *
 * Revisions:
 *   $Log: ID3Genre.cs,v $
 *   Revision 1.2  2004/11/10 06:51:55  cwoodbury
 *   Hid CVS log messages away in #region
 *
 *   Revision 1.1  2004/11/03 01:18:07  cwoodbury
 *   Added to ID3Sharp
 *
 */
#endregion

/* 
 * Author(s):
 *   Chris Woodbury 
 * 
 * Project Location:
 *	 http://id3sharp.sourceforge.net
 * 
 * License:
 *   Licensed under the Open Software License version 2.0
 */

using System;

namespace ID3Sharp
{
	/// <summary>
	/// This class contains a mapping between the integers for ID3v1 genres
	/// and their string values.
	/// </summary>
	public class ID3Genre
	{
		#region Genres
		/// <summary>
		/// An array of all of the genre string values in which the index of
		/// the string its integer value for ID3v1 encoding.
		/// </summary>
		private static string[] genres = {   "Blues",
											 "Classic Rock",
											 "Country",
											 "Dance",
											 "Disco",
											 "Funk",
											 "Grunge",
											 "Hip-Hop",
											 "Jazz",
											 "Metal",
											 "New Age",
											 "Oldies",
											 "Other",
											 "Pop",
											 "R&B",
											 "Rap",
											 "Reggae",
											 "Rock",
											 "Techno",
											 "Industrial",
											 "Alternative",
											 "Ska",
											 "Death Metal",
											 "Pranks",
											 "Soundtrack",
											 "Euro-Techno",
											 "Ambient",
											 "Trip-Hop",
											 "Vocal",
											 "Jazz+Funk",
											 "Fusion",
											 "Trance",
											 "Classical",
											 "Instrumental",
											 "Acid",
											 "House",
											 "Game",
											 "Sound Clip",
											 "Gospel",
											 "Noise",
											 "AlternRock",
											 "Bass",
											 "Soul",
											 "Punk",
											 "Space",
											 "Meditative",
											 "Instrumental Pop",
											 "Instrumental Rock",
											 "Ethnic",
											 "Gothic",
											 "Darkwave",
											 "Techno-Industrial",
											 "Electronic",
											 "Pop-Folk",
											 "Eurodance",
											 "Dream",
											 "Southern Rock",
											 "Comedy",
											 "Cult",
											 "Gangsta",
											 "Top 40",
											 "Christian Rap",
											 @"Pop/Funk",
											 "Jungle",
											 "Native American",
											 "Cabaret",
											 "New Wave",
											 "Psychadelic",
											 "Rave",
											 "Showtunes",
											 "Trailer",
											 "Lo-Fi",
											 "Tribal",
											 "Acid Punk",
											 "Acid Jazz",
											 "Polka",
											 "Retro",
											 "Musical",
											 "Rock & Roll",
											 "Hard Rock",
											 "Folk",
											 "Folk-Rock",
											 "National Folk",
											 "Swing",
											 "Fast Fusion",
											 "Bebob",
											 "Latin",
											 "Revival",
											 "Celtic",
											 "Bluegrass",
											 "Avantgarde",
											 "Gothic Rock",
											 "Progressive Rock",
											 "Psychedelic Rock",
											 "Symphonic Rock",
											 "Slow Rock",
											 "Big Band",
											 "Chorus",
											 "Easy Listening",
											 "Acoustic",
											 "Humour",
											 "Speech",
											 "Chanson",
											 "Opera",
											 "Chamber Music",
											 "Sonata",
											 "Symphony",
											 "Booty Bass",
											 "Primus",
											 "Porn Groove",
											 "Satire",
											 "Slow Jam",
											 "Club",
											 "Tango",
											 "Samba",
											 "Folklore",
											 "Ballad",
											 "Power Ballad",
											 "Rhythmic Soul",
											 "Freestyle",
											 "Duet",
											 "Punk Rock",
											 "Drum Solo",
											 "Acapella",
											 "Euro-House",
											 "Dance Hall",
											 "Goa",
											 "Drum & Bass",
											 "Club-House",
											 "Hardcore",
											 "Terror",
											 "Indie",
											 "BritPop",
											 "Negerpunk",
											 "Polsk Punk",
											 "Beat",
											 "Christian Gangsta Rap",
											 "Heavy Metal",
											 "Black Metal",
											 "Crossover",
											 "Contemporary Christian",
											 "Christian Rock",
											 "Merengue",
											 "Salsa",
											 "Thrash Metal",
											 "Anime",
											 "JPop",
											 "Synthpop" };
		#endregion

		/// <summary>
		/// An array of the ID3v1 genre strings.
		/// </summary>
		public static string[] Genres
		{
			get
			{
				return genres;
			}
		}
  
		/// <summary>
		/// Given an genre integer value, returns the corresponding string.
		/// If no genre exists for that integer, null is returned.
		/// </summary>
		/// <param name="genreInt">The integer value for a genre.</param>
		/// <returns>The string corresponding to the specified integer,
		/// or null if there is no match.</returns>
		public static string GetGenre( int genreInt ) 
		{
			string str = null;

			if( genreInt >= 0 && genreInt < genres.Length ) 
			{
				str = genres[ genreInt ]; 
			}

			return str;
		}
		
		/// <summary>
		/// Given an genre string value, returns the corresponding integer.
		/// If no genre exists for that string, -1 is returned.
		/// </summary>
		/// <param name="genreString">The string value of a genre,
		/// case-insensitive.</param>
		/// <returns>The integer value corresponding to the specifiec string
		/// , or -1 if there is no match.</returns>
		public static int GetGenre( string genreString ) 
		{
			int genre = -1;

			if ( genreString != null )
			{
				int genreItr = 0;
				while ( genre == -1 && genreItr < genres.Length )
				{
					string currentGenre = genres[ genreItr ].ToLower();
					if ( currentGenre.Equals( genreString.ToLower() ) )
					{
						genre = genreItr;
					}
					genreItr++;
				}
			}

			return genre;
		}
	}
}
